<template>
  <!--访问路径-->
  <div class="router-path-box">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <!--<el-breadcrumb-item>首页</el-breadcrumb-item>-->
      <!--<el-breadcrumb-item>活动管理</el-breadcrumb-item>-->
      <el-breadcrumb-item class="path-item">{{ pathArr[0] }}</el-breadcrumb-item>
      <el-breadcrumb-item class="path-item"> {{ pathArr[1] }}</el-breadcrumb-item>
    </el-breadcrumb>
    <el-button v-if="$route.path==='/commonList'" class="reflush-button" @click="bus.$emit('CurrPageReflushBusCall')"
               size="small" type="info" icon="el-icon-refresh">
      刷新
    </el-button>
  </div>
</template>
<script>
/* eslint-disable space-infix-ops */

export default {
  name: 'PagePath',
  data: function () {
    return {
      pathArr: [
        '公共', '首页'
      ]
    }
  },
  watch: {
    $route: function () {
      this.getPathArr(this.$router.currentRoute.fullPath.substr(1))
    }
  },
  mounted: function () {
    this.getPathArr(this.$router.currentRoute.fullPath.substr(1))
  },
  methods: {
    getPathArr: function (url) {
      var $this = this
      $this.GlobalData.MenuArr.forEach(function (value, key) {
        value.subMenu.forEach(function (_value, _key) {
          if (_value.url === url) {
            $this.pathArr[0] = value.name
            $this.pathArr[1] = _value.name
          }
        })
      })
      $this.$forceUpdate()
    }
  }
}
</script>
<style scoped>
.router-path-box {
  height: 23px;
  line-height: 23px;
  width: 100%;
  text-indent: 5px;
  padding-top: 5px;
  font-size: 12px;
  position: relative;
}

.reflush-button {
  position: absolute;
  right: 2px;
  top: 2px;
  height: 22px;
  line-height: 18px;
  padding: 2px 3px;
}

.path-item {
  margin-top: 3px;
}
</style>
